package com.xuelang.pipeline.artifact.client.resource;

import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryAssetBuildHistoryDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryAssetDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryComponentDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryComponentQuery;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 制品组件服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface IRepositoryComponentService {

    /**
     * 查询制品组件列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam 查询条件
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<RepositoryComponentDTO>> pageRepositoryComponentList(@RequestBody @Valid PageParam<RepositoryComponentQuery> dtoPageParam);

    /**
     * 查询制品组件列表(有过滤条件)
     *
     * @param repositoryComponentQuery 查询条件
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<RepositoryComponentDTO>> conditionalRepositoryComponentList(@RequestBody @Valid RepositoryComponentQuery repositoryComponentQuery);
    
    /**
     * 删除制品组件
     *
     * @param restId 制品组件UUID
     * @return
     */
    @DeleteMapping(value = "/{restId}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteRepositoryComponent(@PathVariable("restId") String restId);
    /**
     * 查询制品组件
     *
     * @param restId 制品组件UUID
     * @return
     */
    @GetMapping(value = "/{restId}", produces = "application/json;charset=utf-8")
    ApiResult<RepositoryComponentDTO> queryRepositoryComponent(@PathVariable("restId") String restId);
    /**
     * 查询制品组件下文件列表
     *
     * @param restId 制品组件UUID
     * @return
     */
    @GetMapping(value = "/asset/list/{restId}", produces = "application/json;charset=utf-8")
    ApiResult<List<RepositoryAssetDTO>> listAssetsBytRestId(@PathVariable("restId") String restId);
    /**
     * 镜像文件构建历史列表
     *
     * @param restId 制品组件UUID
     * @return
     */
    @GetMapping(value = "/asset/build/history/{restId}", produces = "application/json;charset=utf-8")
    ApiResult<List<RepositoryAssetBuildHistoryDTO>> dockerArtifactBuildHistory(@PathVariable("restId") String restId);
}
